package app.modules.cloudpivot.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.authine.cloudpivot.engine.api.model.dto.MessageDTO;
import com.authine.cloudpivot.engine.enums.type.IMMessageChannelType;
import com.authine.cloudpivot.engine.enums.type.IMMessageType;
import com.authine.cloudpivot.engine.service.message.MessagePreprocessingService;

/**
 * 消息预处理
 *
 * @author LiuGangQiang Create in 2023/03/16
 */
@Service
public class CustomMessagePreprocessingServiceImpl implements MessagePreprocessingService {
    private static final Logger LOG = LoggerFactory.getLogger(CustomMessagePreprocessingServiceImpl.class);

    /**
     * 默认消息通道可以参考{@link IMMessageChannelType}<br>
     * 默认消息类型可以参考{@link IMMessageType}<br>
     * 一般的逻辑就是拦截站内信然后针对不同消息进行处理
     */
    @Override
    public MessageDTO process(MessageDTO message) {
        /* 只处理站内信 */
        if (message.getChannel().equals(IMMessageChannelType.MAIL.toString())) {
            LOG.info("===>>消息预处理 通道类型:{} 消息类型:{} 消息内容:{}", message.getChannel(), message.getMessageType().getName(), message.getContent());
        }
        return message;
    }
}